home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_07 / guthrie / autoq.cpp < prev    next >
C/C++ Source or Header  |  1994-10-08  |  1KB  |  30 lines

  1. //====================== AUTOQ.CPP ======================================
  2. //  AutoQueue Class Implementation File
  3. //  R. Scott Guthrie - Original Code Creation
  4. //=======================================================================
  5. #include "AUTOQ.HPP"
  6.  
  7. // ----- Constructor (Auto Linking) -----
  8. // Constructor used to create an AutoQueue entry in the specified list.
  9. AutoQueue::AutoQueue(AutoQueue** QHead)
  10. { QHead_ = QHead;             // Save QHead value.
  11.   Next_ = *QHead;             // Next points to top.
  12.   if(Next_)                   // If there is a Next,
  13.     Next_->Previous_ = this;  //   make its Previous point to this instance.
  14.   Previous_ = 0;              // Previous is 0.
  15.   *QHead = this;              // QHead points to this instance.
  16. }
  17.  
  18. // ----- Destructor -----
  19. AutoQueue::~AutoQueue()
  20. { if(QHead_)                         // If this instance is linked...
  21.   { if(!Previous_)                   // If this is the first node
  22.       *QHead_ = Next_;               //   make QHead -> Next
  23.     else                             // Otherwise,
  24.       Previous_->Next_ = Next_;      //   make previous Next -> Next.
  25.     if(Next_)                        // If there is a Next,
  26.       Next_->Previous_ = Previous_;  //   make its Previous -> this Previous.
  27.   }
  28. }
  29. // end file AUTOQ.CPP
  30.